package org.holynite.fieldmanage.entities

import javax.persistence.Column
import javax.persistence.Entity
import javax.persistence.Id
import javax.persistence.Table

/**
 * Created by midnite on 15/1/4.
 */
@Entity
@Table(name = "commodity_storage")
class CommodityStorage implements Serializable {
	@Id
	@Column(name = "comm_id", nullable = false)
	String commodityId
	@Column(name = "packed", nullable = false)
	Integer packedAmount = 0
	@Column(name = "unpacked", nullable = false)
	Integer unpackedAmount = 0
	@Column(name = "damaged_pack", nullable = false)
	Integer damagedPack = 0
	@Column(name = "damaged_unpack", nullable = false)
	Integer damagedUnpack = 0
	@Column(name = "lost_pack", nullable = false)
	Integer lostPack = 0
	@Column(name = "lost_unpack", nullable = false)
	Integer lostUnpack = 0
	@Column(name = "self_consume", nullable = false)
	Integer selfConsume = 0

	boolean equals(o) {
		if (this.is(o)) return true
		if (getClass() != o.class) return false

		CommodityStorage that = (CommodityStorage) o

		if (commodityId != that.commodityId) return false

		return true
	}

	int hashCode() {
		return (commodityId != null ? commodityId.hashCode() : 0)
	}
}
